<template>
  <div>
    <h1>登陆页面</h1>
    <el-button @click="handle" type="success">登录</el-button>
    <el-button  @click="rightis" type="primary">权限</el-button>
    <p>密钥: {{ token }}</p>
  </div>
</template>

<script>
import axios from 'axios'

export default {
  data() {
    return {
        token:''
    }
  },
  methods: {
    async handle() {
      let param = {
        username: 'admin',
        password: '123456'
      }
      // 修正 URL 地址中的斜杠
      let url = 'http://127.0.0.1:8888/api/private/v1/login';
      let ret = await axios.post(url, param)
      //保存数据
      this.token=ret.data.data.token
      localStorage.setItem('token',this.token)
      console.log(ret);

    },
    async rightis(){
        axios.defaults.headers['Authorization']=localStorage.getItem('token');
         let url = 'http://127.0.0.1:8888/api/private/v1/rights/list';
      let rets = await axios.get(url)
      console.log(rets);
    }
  }
}
</script>



<style>

</style>